#ifndef FKUSERINTERFACE_H
#define FKUSERINTERFACE_H

#include "FKApplication_global.h"

#include <QObject>
#include <QStringList>
#include <QMap>
#include <QVariant>

class FKGLWidget;
class FKEvent;
class FKClient;
class FKRoom;
class FKUser;
class FKFilesList;
class FKMenuInterface;
class FKRoomInterface;
class FKWorldReferent;
class FKRoomModule;

class FKAPPLICATIONSHARED_EXPORT FKUserInterface : public QObject{
    Q_OBJECT
public:
    FKUserInterface(QObject *parent = 0);
    ~FKUserInterface();
    void setAvaliableRoomTypes(const QList<FKRoomModule*> &lst);
    void show();
    void start();
    void setMenuInterface(FKMenuInterface* menu=0);
    void managerCreated(QString managerType);
    void managerReseted();
    void managerCreationFalied();
    FKClient* activeClient();
//    void regWorld(const QMetaObject* w){_worldFactory[w->className()]=w;}
//    void regInterface(const QMetaObject* i){_interfaceFactory[i->className()]=i;}
public slots:
    void message(const QString m);

    virtual void setDownloaded(QString file, quint8 osType, qint64 size);
    virtual void setDownloadComplete(QString file, quint8 osType, bool success);
signals:
    void soundAsked(QString soundName);
    void musicAsked(QString trackName);
    void managerRequested(QString managerType, QString ip, int port);
    void clientRequested(QString clientName, QString password);
    void genClient(QString clientName, QString password);
    void newAction(FKEvent* event);

    void appFileUpdateRequested(QString fl, quint8 osType);
    void stopAppFilesDLRequested();
    void appFilesReplaceRequested(QStringList files, QList<quint8> os);
protected:
    virtual FKUser* activeUser();
    FKRoom* activeRoom();
    void setUpdateFilesList(FKFilesList &server, FKFilesList &local);
    virtual void installMenuInterface();
//    FKWorldReferent* createWorld(const QString& className) const;
//    FKRoomInterface* createRoomInterface(const QString &className) const;
protected slots:
//    void updateUsers();
    virtual void roomChosen(FKRoom* room);
    void roomListUpdateRequested();
private slots:
    void worldAction(qint32 object, QString subject, QVariant value, qint32 emitter);
    void enterRoomRequested(qint32 roomID);
    void createRoomRequested(QString roomType,QString roomName,QString description,QString password);
    void startRoomRequested();
    void setClient(FKClient* client);
    void genUser(QString userName);
    void degenUser(QString userName);
    void chooseUser(QString userName);
    void releaseUser(QString userName);
//    void updateUserList(QStringList userList);
    void submitUsers();
    void messageRequested(QString message);
//    virtual void roomListUpdated(QMap<qint32,QString> roomList);
    virtual void publicMessage(QString message);
    virtual void privateMessage(QString message);
    virtual void commandMessage(QString message);
    virtual void chatErrorMessage(QString message);
    virtual void roomResetRequested();
    void managerResetRequested();
//    void sceneLoadingComplete();
    void roomLoadingComplete();
private:
    FKClient* _client;
    FKRoom* _room;
    FKMenuInterface* _menu;
//    QMap<QString,const QMetaObject*> _worldFactory;
//    QMap<QString,const QMetaObject*> _interfaceFactory;
    FKWorldReferent* _world;
    FKRoomInterface* _roomInterface;
    QMap<QString,QString> _roomTypes;
};

#endif // FKUSERINTERFACE_H
